﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using ExtendPropertyLib.WPF;
using ExtendPropertyLib;
using ExORMDesginer.Services;
using ExORMDesginer.RadWindow.Helper;
using ExORMDesginer.Models;

namespace ExORMDesginer.UserControls.Dialogs
{
    public class ConnectionVSIdeDialogViewModel:ViewModelBase<ConnectionVSIdeDialogInfo>
    {
        private RadWindowManager RadWindow = new RadWindowManager();

        public override void OnDoCreate(ExtendObject item, params object[] args)
        {
            base.OnDoCreate(item, args);
            if(Model.RunningIDEs.Count > 0)
                SelectInfo = Model.RunningIDEs[0];

        }

        public override string GetViewTitle()
        {
            return "连接VS编辑器服务";
        }

        
        public static ExtendProperty InfoProperty = RegisterProperty<ConnectionVSIdeDialogViewModel>(m => m.SelectInfo);
        /// <summary>
        /// 当前选择的编辑器
        /// </summary>
        public IDEInfo SelectInfo
        {
            set
            {
                SetValue(InfoProperty, value);
            }
            get
            {
                return (IDEInfo)GetValue(InfoProperty);
            }
        }


        public void Connection()
        {
            if(SelectInfo!=null)
                Model.ConnectIDE(SelectInfo);
                this.TryOK();
        }


        public void Cancel()
        {
            this.TryCancel();
        }

        public void Test()
        {
            var viewModel = ViewModelFactory.GetModel<SolutionBowserDialogViewModel>();
            RadWindow.ShowDialog(viewModel);
        }



    }
}
